<template>
	<view class="u-flex-col">
		<worker-header>
			<view class="content-wrap">
				<view class="border-wrap item" v-for="(item, index) in list" :key="index" @click="go_case(item.id)">
					<case-detail :item="item"></case-detail>
				</view>
			</view>
		</worker-header>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				workerTypeName: "工长",
				userinfo: {},
				userObj: {},
				list: [],
			}
		},
		onLoad(options) {
			let data = JSON.parse(options.item)
			if (data.level == 1) {
				this.workerTypeName = "用户";
			} else if (data.level == 2) {
				this.workerTypeName = "个人工匠";
			} else if (data.level == 3) {
				this.workerTypeName = "公司工匠";
			} else if (data.level == 5) {
				this.workerTypeName = "区域服务商 ";
			}
			this.userinfo = data;
			this.getList(data.user_id)
		},
		methods: {
			getList(id) {
				console.log(id)
				this.$api.get({
					url: '/worker/comment/caseList',
					data: {
						user_id: id
					},
					success: res => {
						console.log(res)
						this.list = res.data;
					}
				})
			},
			go_case(case_id) {
				console.log(case_id)
			},
			go_case_list(user_id) {
				console.log(user_id)
				uni.navigateTo({
					url: 'case-list?user_id' + user_id,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>
<style lang="scss" scoped>
	.content-wrap {
		margin-top: 70rpx;
		border-radius: 14rpx 14rpx 0 0;
		position: relative;
		top: -34rpx;
		margin-bottom: -34rpx;
		background: #F5F5F5;
	}


	.item {
		border-radius: 14rpx;

		&+& {
			margin-top: 16rpx;
		}
	}
</style>